package asia.yuanding.wechat.system.config;

import asia.yuanding.wechat.system.util.ThreadUser;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @ClassName: MybatisPlusConfig
 * @Author: YuanDing
 * @Date: 2025/7/26 21:06
 * @Description:
 */

// java example
@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {



    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("开始插入填充...");

        this.strictInsertFill(metaObject, "createUser", String.class, ThreadUser.getUId());
        this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("开始更新填充...");
        this.strictInsertFill(metaObject, "updateUser", String.class, ThreadUser.getUId());
        this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
    }
}